package com.qpx.jxcmessage.confirm;


import com.alibaba.fastjson.JSON;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@Component(value = "Producer-confirm")
public class Producer {


    @Autowired
    RabbitTemplate rabbitTemplate;


    public void sendMessage(){
        Map<String,Object> map = new HashMap<>();
        String uuid = UUID.randomUUID().toString();
        map.put("uuid", uuid);
        map.put("obj","confirm-test");
        String message = JSON.toJSONString(map);
        CorrelationData correlationData = new CorrelationData(uuid);
        rabbitTemplate.convertAndSend("exchange-confirm-test","confirm.#",message,correlationData);
    }
}
